package controller;

import core.BaseServlet;
import service.BillService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "BillServlet", urlPatterns = "/bill")
public class BillServlet extends BaseServlet {

    private BillService billService = new BillService();

    /**
     * 按条件查找账单信息
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void findBillByParam(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        billService.findBillByParam(request, response);
    }

    /**
     * 账单管理页面
     *
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void billManagePage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/WEB-INF/pages/billManage/billManage.jsp").forward(request, response);
    }

    /**
     * 添加账单页面
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void addPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/WEB-INF/pages/billManage/billAdd.jsp").forward(request, response);
    }

    /**
     * 添加账单
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    public void addBill(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        billService.addBill(request, response);
    }
}
